package com.service.business.news.controller;

import com.service.business.support.SessionUtil;
import com.service.core.rest.BaseController;
import com.service.core.rest.response.OneResponse;
import com.service.core.rest.response.PageResponse;
import com.service.dao.enums.CommonStatusEnums;
import com.service.business.framework.log.RequestLog;
import com.service.business.news.controller.rep.NewsDetailRep;
import com.service.business.news.controller.rep.NewsPageRep;
import com.service.business.news.controller.req.NewsPageReq;
import com.service.business.news.service.NewsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 系统公告
 *
 * @author xxxx
 * @email xxxx@qq.com
 * @date 2019-11-12 21:59:44
 */
@Slf4j
@RestController
@RequestMapping("news")
public class NewsController extends BaseController {
    @Autowired
    private NewsService newsService;

    @RequestLog("系统公告分页查询")
    @PostMapping("/page")
    public PageResponse<NewsPageRep> page(@RequestBody NewsPageReq newsPageReq){
        return successQueryPageResponse(newsService.pageNews(CommonStatusEnums.ACTIVE.getCode(),newsPageReq));
    }

    @RequestLog("系统公告详情")
    @GetMapping("/detail/{newsId}")
    public OneResponse<NewsDetailRep> newsDetail(@PathVariable Integer newsId){
        log.info("NewsController.newsDetail start,newsId:{}",newsId);
        return successQueryOneResponse(newsService.getOneNewsDetail(newsId));
    }

}
